package com.reggie.service.model.bo;

import com.reggie.acl.dataobject.Dish;
import com.reggie.acl.dataobject.DishFlavor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

/**
 * 菜品 数据传输类
 *
 * @author yth
 * @since 2023/2/6 1:17
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class DishBO extends Dish {

    public DishBO() {
    }

    public DishBO(Dish dish) {
        Optional.ofNullable(dish)
                .ifPresent(e -> BeanUtils.copyProperties(e, this));
        this.flavors = Collections.emptyList();
    }

    /**
     * 菜品对应的口味数据
     */
    private List<DishFlavor> flavors;

    /**
     * 菜品分类名称
     */
    private String categoryName;

    /**
     * 菜品份数
     */
    private Integer copies;

}
